//# sourceURL=http://uMapApp/Module/HomeYSModule
define([
    "mhjs/mhjs",
    "uMap/uMap",
    "uEarth/uEarth",
    "../Module",
    "../../UI/Panel/FloatPanel",
    "../../UI/Panel/PanelBlock/PanelBlock",
    "../../UI/Panel/PanelBlock/ListBlock",
    "../../UI/Panel/Item/EquipmentListItem"
], function (
    mhjs,
    uMap,
    uEarth,
    Module,
    FloatPanel,
    PanelBlock,
    ListBlock,
    EquipmentListItem
) {

    function HomeYSModule(option) {

        var _this = this;

        Module.call(_this, option);

        _this.title = "有形资产";
        _this.icon = _this.app.icons.home;

        _this.leftPanel = new FloatPanel({"class": "leftPanel", "showMinMax": true, "title": "简介 / 道路设施"});

        _this.leftPanel.infoBlock = new PanelBlock({
            "title"  : "沪渝高速简介",
            "content": "　　沪苏浙高速公路（江苏段）起点位于吴江市芦墟镇北的苏沪两省交界处，与上海沪青平高速公路相接，进过莘塔、北厍、古池荡、八都，终点位于吴江市震泽镇八都北的苏沪两省交界处，与浙江省申苏沪皖高速公路相接，江苏段路线全长49.947公路。全线为双向六车道，全封闭、全立交，路基宽度35米，计算行车速度120km/h。"
        });


        _this.leftPanel.equipmentsBlock = new ListBlock({
            "class": "equipmentBlock",
            "title": "道路设施",
            "list" : [
                _this.createModuleButton({
                    "title"   : "路面",
                    "icon"    : _this.app.icons.road.base64,
                    "unit"    : "KM",
                    "count"   : 49.947
                    , "module": _this.app.modules.road.roadCenterStakeNumModule
                }),
                _this.createModuleButton({
                    "title"   : "桥梁",
                    "icon"    : _this.app.icons.bridge.base64,
                    "unit"    : "座",
                    "count"   : 73
                    , "module": _this.app.modules.road.stakeNumDataModules.bridgeModule
                }),
                _this.createModuleButton({
                    "title"   : "长大桥",
                    "icon"    : _this.app.icons["长大桥"].base64,
                    "unit"    : "座",
                    "count"   : 44
                    , "module": _this.app.modules.road.stakeNumDataModules.longbridgeModule
                }),
                _this.createModuleButton({
                    "title": "隧道",
                    "icon" : _this.app.icons["隧道"].base64,
                    "unit" : "个",
                    "count": 0
                }),
                _this.createModuleButton({
                    "title"   : "服务区",
                    "icon"    : _this.app.icons["服务区"].base64,
                    "unit"    : "对",
                    "count"   : 1
                    , "module": _this.app.modules.road.stakeNumDataModules.serverAreaModule
                }),
                _this.createModuleButton({
                    "title": "通道涵洞",
                    "icon" : _this.app.icons["涵洞"].base64,
                    "unit" : "个",
                    "count": 121
                }),
                _this.createModuleButton({
                    "title"   : "枢纽",
                    "icon"    : _this.app.icons["枢纽"].base64,
                    "unit"    : "个",
                    "count"   : 2
                    , "module": _this.app.modules.road.stakeNumDataModules.pivotModule
                }),
                _this.createModuleButton({
                    "title"   : "互通",
                    "icon"    : _this.app.icons["互通"].base64,
                    "unit"    : "个",
                    "count"   : 6
                    , "module": _this.app.modules.road.stakeNumDataModules.interchangeModule
                }),
                _this.createModuleButton({
                    "title"   : "收费站",
                    "icon"    : _this.app.icons["收费站"].base64,
                    "unit"    : "个",
                    "count"   : 6
                    , "module": _this.app.modules.road.stakeNumDataModules.tollgateModule
                }),
                _this.createModuleButton({
                    "title": "工业区",
                    "icon" : _this.app.icons["工业园区"].base64,
                    "unit" : "个",
                    "count": 0
                }),
                _this.createModuleButton({
                    "title": "绿化种类",
                    "icon" : _this.app.icons["绿化"].base64,
                    "unit" : "种",
                    "count": 0
                })
            ]
        });

        _this.leftPanel
            .append(_this.leftPanel.infoBlock)
            .append(_this.leftPanel.equipmentsBlock);

        _this.rightPanel = new FloatPanel({"class": "rightPanel", "showMinMax": true, "title": "交安 / 营运"});

        _this.rightPanel.safeBlock = new ListBlock({
            "class": "equipmentBlock",
            "title": "交安附属设施",
            "list" : [
                _this.createModuleButton({
                    "title"   : "护栏",
                    "icon"    : _this.app.icons.maintain.base64,
                    "unit"    : "KM",
                    "count"   : 87
                    , "module": _this.app.modules.road.benchModule
                }),
                _this.createModuleButton({
                    "title"   : "标志标牌",
                    "icon"    : _this.app.icons.maintain.base64,
                    "unit"    : "个",
                    "count"   : 65
                    , "module": _this.app.modules.road.signModule
                }),
                _this.createModuleButton({
                    "title": "隔离栏",
                    "icon" : _this.app.icons.maintain.base64,
                    "unit" : "KM",
                    "count": 45
                }),
                _this.createModuleButton({
                    "title"   : "声屏障",
                    "icon"    : _this.app.icons.maintain.base64,
                    "unit"    : "KM",
                    "count"   : 5.5
                    , "module": _this.app.modules.road.soundBenchModule
                })
            ]
        });


        _this.rightPanel.operationBlock = new ListBlock({
            "class": "equipmentBlock",
            "title": "营运设备",
            "list" : [
                _this.createModuleButton({
                    "title"      : "ETC门架",
                    "icon"       : _this.app.icons.maintain.base64,
                    "unit"       : "个",
                    "count"      : 24,
                    "errorLabel" : "异常 ",
                    "errorCount" : 0,
                    "normalLabel": "正常",
                    "normalCount": 24
                    , "module"   : _this.app.modules.road.etcModule
                }),
                _this.createModuleButton({
                    "title"      : "监控点",
                    "icon"       : _this.app.icons.camera.base64,
                    "unit"       : "个",
                    "count"      : 22,
                    "errorLabel" : "异常",
                    "errorCount" : 0,
                    "normalLabel": "正常",
                    "normalCount": 6
                    , "module"   : _this.app.modules.road.cameraBridgeModule
                }),
                _this.createModuleButton({
                    "title"      : "气象站",
                    "icon"       : _this.app.icons.maintain.base64,
                    "unit"       : "个",
                    "count"      : 4,
                    "errorLabel" : "异常",
                    "errorCount" : 0,
                    "normalLabel": "正常",
                    "normalCount": 4
                    , "module"   : _this.app.modules.road.weatherGeterModule
                }),
                _this.createModuleButton({
                    "title"      : "称重设备",
                    "icon"       : _this.app.icons.maintain.base64,
                    "unit"       : "个",
                    "count"      : 2,
                    "errorLabel" : "异常",
                    "errorCount" : 0,
                    "normalLabel": "正常",
                    "normalCount": 2
                    , "module"   : _this.app.modules.road.loadometerModule
                })
            ]
        });

        _this.rightPanel
            .append(_this.rightPanel.safeBlock)
            .append(_this.rightPanel.operationBlock);

        _this.app.ui.layout.left.append(_this.leftPanel);
        _this.app.ui.layout.right.append(_this.rightPanel);

    }

    var _class = HomeYSModule;

    mhjs.Inherit(_class, Module);

    Object.defineProperties(_class.prototype, {
        "open"              : {
            value: function (stopPropagation) {

                var _this = this;

                if (!_this.isOpened) {

                    _this.leftPanel.open(false);
                    _this.leftPanel.max(false);
                    _this.rightPanel.open(false);
                    _this.rightPanel.max(false);
                    _this.app.flyHome(true);
                    _this.isOpened = true;
                    stopPropagation !== false && _this.trigger("open");
                }
            }
        },
        "close"             : {
            value: function (stopPropagation) {

                var _this = this;

                if (_this.isOpened) {
                    _this.leftPanel.close();
                    _this.rightPanel.close();
                    _this.isOpened = false;
                    stopPropagation !== false && _this.trigger("close");
                }
            }
        },
        "toggle"            : {
            value: function () {
                var _this = this;
                if (_this.isOpened) {
                    _this.close();
                } else {
                    _this.open();
                }
            }
        },
        "createModuleButton": {
            value: function (option) {
                var _this = this;

                var button = new EquipmentListItem(option);

                if (button.module) {
                    button.on("click", function () {
                        button.module.toggle(false);
                        button.toggleClass("active");
                    });
                }

                return button;


            }
        }
    });

    return _class;

});